package cn.mesmile.thread.single;

/**
 * @author zb
 * @date 2020/12/31 14:33
 * @Description 单例模式
 */
public class SingleInstance {

    private SingleInstance(){}

    private volatile static SingleInstance singleInstance = null;

    public static SingleInstance getSingleInstance(){
        if (singleInstance == null) {
            synchronized (SingleInstance.class){
                if (singleInstance == null) {
                    singleInstance = new SingleInstance();
                }
            }
        }
        return singleInstance;
    }

}
